<!--基本业务查询-大小额基本业务查询-->
<template>
  <div class="app-container">
    <ht-search-form
      :dictMap="dictMap"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :beforeSearchCallback="false"
      @beforeSearchCallback="beforeSearchCallback"
      :clearCallBack="clearCallBack"
    >
      <template slot="endSlotOption">
        <amount-range-search label="金额区间" ref="amountRangeSearch"></amount-range-search>
      </template>
    </ht-search-form>
    <ht-table
      ref="dataTable"
      rowKey="id"
      :showSerialNumber="false"
      :multi-select="false"
      :dictMap="dictMap"
      :reqConfig="reqConfig"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    toViewDetail(scope.row);
                  },
                }
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>
    <query-detail-dialog ref="queryDetailDialog" :dictMap="dictMap"></query-detail-dialog>
  </div>
</template>
<script>

import { apiUrlConfig } from "@/api/cnaps/baseBiz/inquire/141/index";
import QueryDetailDialog from "./components/Details";
import { listPageMixin } from "@/libs/listPageMixin";
import AmountRangeSearch from "@/views/components/AmountSearchInput";
export default {
  name: "baseBizInq141Index",
  mixins: [listPageMixin],
  components: {
    AmountRangeSearch,
    QueryDetailDialog,
  },
  watch: {
    dictMap: {
      handler(data) {
      },
    },
  },
  data() {
    return {
      reqConfig: apiUrlConfig,
      //数据字典
      searchFormDictList: [
        'Cnaps2Dict.CP2_STATUS',
        "Cnaps2Dict.BIZ_TYPE_141",
        "BIZ_CTGY","SYSTEMCODE",
        "DRCTCODE","TXN_SOURCE",
        "Cnaps2Dict.NOTICETYPE",
        "PKG_STATUS","PROCESSSTATUS"

      ],
      // 日期范围
      dateRange: [],
      bizList:[],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: "",
        workdate: '',
        workdate2: '',
        drct: '',
        sysCode: "",
        status: "",
        pkgNo: "",
        amount1: "",
        amount2: "",
        bizTypeCode:"",
        bizCtgyCode:"",

      },
      formOptions: [],
      tableBindColumns: [
        { label: `内部机构号`, prop: "brno", dictCode: "Cnaps2Dict.CP2_BRNO", width: "160" },
        { label: `系统编号`, prop: "sysCode", dictCode: 'Cnaps2Dict.SYS_CODE', width: "160" },
        { label: `交易流水号`, prop: "id", width: "160" },
        { label: `工作日期`, prop: "workdate" },
        { label: `报文标识号`, prop: "pkgId", width: 160 },
        { label: `业务类型`, prop: "bizTypeCode",dictCode:"Cnaps2Dict.BIZ_TYPE_141", sortable: false, width: 140 },
        { label: `业务种类`, prop: "bizCtgyCode", dictCode:"BIZ_CTGY", sortable: false, width: 200
        },
        {
          label: `来往账标志`,
          prop: "drct",
          width: "100",
          dictCode: "Cnaps2Dict.DRCTCODE",
          sortable: false,
        },
        {
          label: `金额`,
          prop: "amount",
          type: 'price',
          sortable: false,
        },
        {
          label: `来源`,
          prop: "source",
          dictCode: "TXN_SOURCE",
          sortable: false,
        },
        {
          label: `通讯状态`,
          prop: "status",
          dictCode: "Cnaps2Dict.PKG_STATUS",
          sortable: false,
          width: 140
        }
      ],
    };
  },
  async mounted() {
    this.$refs.amountRangeSearch.$on('getAmountRange',this.beforeSearchCallback);

    this.formOptions = [
      {
        type: "input",
        prop: "id",
        defaultAttr: {
          label: "流水号",
          placeholder: "请输入交易流水号",
        },
      },
      {
        type: "search-dept-tree",
        prop: "brno",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          label: "工作日期",
          placeholder: ["请输入开始日期", "请输入结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
      {
        type: "dict",
        dict: "Cnaps2Dict.BIZ_TYPE_141",
        prop: "bizTypeCode",
        defaultAttr: {
          label: "业务类型",
          placeholder: "请选择业务类型",
        },
        linkedRules: [
          {
            ruleType: "callbackFn",
            callback: (item, form, formListOptions, rowData, initFlag, formDiarules) => {
              //联动修改bizCtgyCode
              let dictKeyPre = `BIZ_CTGY_HVPS_${form["bizTypeCode"]}`;
              this.getDicts(dictKeyPre).then((response) => {
                if(response===undefined||response===null){
                  formListOptions[4].selectOptionList = [];
                  this.$set(form, "bizCtgyCode", "");
                }else{
                formListOptions[4].selectOptionList = response.result.map((x) => {
                  return {label: x.value+'-'+x.text, value: x.value};
                });
                  this.$set(form, "bizCtgyCode", "");
              }
              });
            },
          }
        ],
      },
      {
        type: "select",
        prop: "bizCtgyCode",
        defaultAttr: {
          label: "业务种类",
          placeholder: "请选择业务种类",
        },
      },
    ];
  },
  methods: {
    beforeSearchCallback() {
      // 搜索按钮之前先执行
      this.queryParams.amount1 = this.$refs.amountRangeSearch.getAmount1();
      this.queryParams.amount2 = this.$refs.amountRangeSearch.getAmount2();
    },
    clearCallBack() {
      let that = this;
      return new Promise(function (resolve, reject) {
        that.$refs.amountRangeSearch.clearAmount();
        that.queryParams.amount1 = "";
        that.queryParams.amount2 = "";
      });
    },
    editComplete(state) {
      console.log("editComplete", state);
      if (state == true) {
        this.getList();
      }
    },
    /** todo 查询当天操作员的交易记录 */
    getList() {
      this.doQuery();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /*查看明细*/
    toViewDetail(row) {
      this.$refs.queryDetailDialog.show(row);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}
</style>
